package com.example.testspringboot.serve.impl;

import com.example.testspringboot.bean.Cate1;
import com.example.testspringboot.bean.Cate2;
import com.example.testspringboot.bean.Cate3;
import com.example.testspringboot.serve.CateServiceInf;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service("cateService")
public class CateServiceImpl implements CateServiceInf {
    @Override
    public void test() {
        StringBuilder test = new StringBuilder("test");
        StringBuilder test1 = test.append("test");
        System.out.println(test1);

        Cate1 cate1 = new Cate1();
        cate1.setId(1);
        cate1.setName("测试");
        cate1.setValue("测试");
        cate1.setType("测试");
        Cate2 cate2 = convertToCate2(cate1);
        System.out.println(cate2);

        Cate3 cate3 = new Cate3();

        cate3.setId(cate1.getId());
        List<Cate1> cate1s = new ArrayList<>();
        cate1s.add(cate1);

    }
    public Cate3 convertToCate3(Cate1 cate1) {
        Cate3 cate3 = new Cate3();
        cate3.setId(cate1.getId());
        cate3.setName(cate1.getName());
        cate3.setValue(cate1.getValue());
        cate3.setType(cate1.getType());
        cate3.setUnit(cate1.getUnit());
        cate3.setColor(cate1.getColor());
        cate3.setIcon(cate1.getIcon());
        return cate3;

    }


    public Cate2 convertToCate2(Cate1 cate1) {
        Cate2 cate2 = new Cate2();
        cate2.setId(cate1.getId());
        cate2.setName(cate1.getName());
        cate2.setValue(cate1.getValue());
        cate2.setType(cate1.getType());
        cate2.setUnit(cate1.getUnit());
        cate2.setColor(cate1.getColor());
        cate2.setIcon(cate1.getIcon());
        return cate2;

    }
}
